<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V5是一个基于Bootstrap v5.1.3的后台管理系统的HTML模板。">
<title>{:$configs['SYSTEM_NAME']}</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/style.min.css">
<!--日期选择器css-->
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/js/bootstrap-datepicker/bootstrap-datepicker3.min.css">
<!--时间日期选择器css-->
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css">

<link rel="stylesheet" type="text/css" href="__STATIC__/common/cch.css">
</head>
  
<body>
<div class="container-fluid">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          <div class="card-search mb-2-5">
            <form class="search-form" method="get" action="{:url('index')}" >
              
              {include file="html/search" /}

              <div class="row">
                <div class="col-md-2">
                    <div class="btn-group btn-group-justified" style="width: auto;">
                        <?php foreach ($date_type as $param_k => $param_v): ?>
                        <button class="btn {:$param_k==input('date_type')?'btn-success':'btn-default'}" data-type="{:$param_k}" type="button">{:$param_v}</button>
                        <?php endforeach ?>
                        <input type="hidden" name="date_type" value="{:input('date_type',0)}" />
                    </div>
                </div>
                <div id="search_time" class="row col-md-4">
                    <div class="col-md-2 mb-2">
                        <div class="input-group">
                            <span class="input-group-btn"><button class="btn btn-default" type="button">开始日期</button></span>
                            <input type="text" class="form-control" data-provide="datepicker" data-autoclose="true" id="start_time" name="start_time" value="{:input('start_time')}" autocomplete="off"/>
                        </div>
                    </div>
                    <div class="col-md-2 mb-2">
                        <div class="input-group">
                            <span class="input-group-btn"><button class="btn btn-default" type="button">结束时间</button></span>
                            <input type="text" class="form-control" data-provide="datepicker" data-autoclose="true" id="end_time" name="end_time" value="{:input('end_time')}" autocomplete="off"/>
                        </div>
                    </div>
                </div>
              </div>
              
            </form>
          </div>
          <div class="card-btns mb-2-5">
            <a class="btn btn-primary me-1 search_btn" href="#!"><i class="mdi mdi-magnify"></i> 搜索</a>
            <a class="btn btn-success me-1" href="{:url('add')}"><i class="mdi mdi-plus"></i> 新增</a>
            <a class="btn btn-danger more_delete_btn" href="#!" data-url='{:url("moreDelete",[],"")}'><i class="mdi mdi-window-close"></i> 删除</a>
          </div>
          <div class="table-responsive">
            <table class="table table-bordered">
              <thead>
                <tr>
                  <th>
                    <div class="form-check">
                      <input class="form-check-input" type="checkbox" id="check-all">
                      <label class="form-check-label" for="check-all"></label>
                    </div>
                  </th>
                  <th>类型</th>
                  <th>日期</th>
                  <th>标题</th>
                  <th width="400px">内容</th>
                  <th>推送用户</th>
                  <th width="300px">概括</th>
                  <th>状态</th>
                  <th>创建时间</th>
                  <th>推送时间</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                <?php if (empty($list)): ?>
                  <tr><td colspan="100" class="text-center">暂无数据</td></tr>
                <?php else: ?>
                  <?php foreach ($list['data'] as $k => $vo): ?>
                    <tr>
                      <td>
                        <div class="form-check">
                          <input type="checkbox" class="form-check-input ids" name="ids[]" value="{:$vo['id']}" id="ids-{:$vo['id']}">
                          <label class="form-check-label" for="ids-{:$vo['id']}"></label>
                        </div>
                      </td>
                      <td>{:$model->getTypeCn($vo['type'])}</td>
                      <td>{:$vo['cdate']}</td>
                      <td>{:$vo['title']}</td>
                      <td>{:truncateString($vo['content'],100)}
                        <a class="btn btn-sm btn-default view_btn" data-id="{:$vo['id']}" data-type="content" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modal-view" title="详情"><i class="mdi mdi-eye"></i></a></td>
                      <td title="{:$vo['user']}">{:truncateString($vo['user'],50)}
                        <a class="btn btn-sm btn-default user_btn" data-id="{:$vo['id']}" data-uid="{:$vo['user_id']}" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modal-users" title="设置发送用户"><i class="mdi mdi-account"></i></a></td>
                      <td>{:truncateString($vo['summarize'],50)}
                        <a class="btn btn-sm btn-default view_btn" data-id="{:$vo['id']}" data-type="summarize" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modal-view" title="详情"><i class="mdi mdi-eye"></i></a></td>
                      <td>{:$model->getStatusCn($vo['status'])}</td>
                      <td>{:timeDef($vo['ctime'])}</td>
                      <td>{:timeDef($vo['utime'])}</td>
                      <td class="text-center">
                          <div class="btn-group btn-group-sm">
                              <a class="btn btn-sm btn-default content_btn" data-id="{:$vo['id']}" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modal-view" title="详情"><i class="mdi mdi-eye"></i></a>
                              <a class="btn btn-xs btn-default" href="{:url('sendEmail',['id'=>$vo['id']])}" data-toggle="tooltip" title="发送邮件"><i class="mdi mdi-send"></i></a>
                              <a class="btn btn-xs btn-default" href="{:url('edit',['id'=>$vo['id']])}" data-toggle="tooltip" title="编辑"><i class="mdi mdi-pencil"></i></a>
                              <a class="btn btn-xs btn-default delete_btn" href="{:url('delete',['id'=>$vo['id']])}" data-toggle="tooltip" title="删除"><i class="mdi mdi-delete"></i></a>
                          </div>
                      </td>
                    </tr>
                  <?php endforeach ?>
                <?php endif ?>
              </tbody>
            </table>
          </div>

          {$page|raw}
          
          
        </div>
      </div>
    </div>
        
  </div>
  
</div>

<div class="modal" tabindex="-1" id="modal-view">
  <div class="modal-dialog modal-dialog-centered modal-xl">
    <div class="modal-content">
      <div class="modal-header">
        <h6 class="modal-title">详情</h6>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body" style="white-space: pre-line;">
        
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>


<div class="modal fade bs-example-modal-lg in" tabindex="-1" id="modal-users">
  <div class="modal-dialog modal-xl modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h6 class="modal-title" id="exampleModalLiveLabel">发送用户</h6>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <form action="{:url('setUserId')}" method="post">
        <input type="hidden" name="report_id" value="" />
        <div class="modal-body" style="max-height:400px;overflow-y: auto;">
          <table class="table table-bordered">
              <thead>
                <tr>
                    <th>
                        <div class="form-check">
                          <input class="form-check-input" type="checkbox" id="check-all">
                          <label class="form-check-label" for="check-all"></label>
                        </div>
                    </th>
                    <th>用户名</th>
                    <th>姓名</th>
                    <th>邮箱</th>
                </tr>
              </thead>
              <tbody>
                <?php if (empty($users)): ?>
                  <tr><td colspan="100" class="text-center">暂无数据</td></tr>
                <?php else: ?>
                  <?php foreach ($users as $k => $vo): ?>
                    <tr>
                      <td>
                        <div class="form-check">
                          <input type="checkbox" class="form-check-input" name="user_id[]" value="{:$vo['id']}" id="uid-{:$vo['id']}">
                          <label class="form-check-label" for="uid-{:$vo['id']}"></label>
                        </div>
                      </td>
                      <td>{:$vo['account']}</td>
                      <td>{:$vo['truename']}</td>
                      <td>{:$vo['email']}</td>
                    </tr>
                  <?php endforeach ?>
                <?php endif ?>
              </tbody>
            </table>
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-success" data-bs-dismiss="modal">保存</button>
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
        </div>
      </form>
    </div>
  </div>
</div>


<script type="text/javascript" src="__STATIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/popper.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/main.min.js"></script>
<!--日期选择器js-->
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<!--时间日期选择器js-->
<script type="text/javascript" src="__STATIC__/admin/js/momentjs/moment.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/momentjs/locale/zh-cn.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/js/lyear-loading.js"></script><!-- loading -->
<!--自定义扩展-->
<script type="text/javascript" src="__STATIC__/common/cch.js"></script>

<script type="text/javascript">
  $('.view_btn').on('click',function(){
      var id = $(this).attr('data-id');
      var type = $(this).attr('data-type');
      $.ajax({
          url:'{:url("detail")}',
          data:{id:id,type:type},
          type:'post',
          dataType:'json',
          success:function(data){
            console.log(data)
            $("#modal-view .modal-body").html(data.data);
          }
      });
  });

  $('.content_btn').on('click',function(){
      var id = $(this).attr('data-id');
      $.ajax({
          url:'{:url("mailContent")}',
          data:{id:id},
          type:'post',
          dataType:'json',
          success:function(data){
            console.log(data)
            $("#modal-view .modal-body").html(data.data);
          }
      });
  });

    $(".user_btn").on('click',function(){
        var report_id = $(this).attr('data-id');
        var user_ids = $(this).attr('data-uid');
        $("#modal-users").find('input[name="report_id"]').val(report_id);
        $("#modal-users").find('input[type="checkbox"]').prop('checked', false);

        if (user_ids != null && user_ids != '') {
            user_ids = user_ids.split(',');
            $("#modal-users").find('input[name="user_id[]"]').val(user_ids);
        }
    });
</script>

<script type="text/javascript">
    $('.btn-group button').on('click',function(){
        var type = $(this).attr('data-type');
        $('input[name="date_type"]').val(type);

        $('.btn-group button').attr('class','btn btn-default');
        $(this).attr('class','btn btn-success');
        if (type == 0) {
            $("#search_time").show();
        }else{
            $("#search_time").hide();
        }
    });

    $(function(){
      var date_type = $('input[name="date_type"]').val();
      if (date_type == 0) {
          $("#search_time").show();
      }else{
          $("#search_time").hide();
      }
    });
</script>
</body>
</html>